diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-14 17:16:53 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-14 17:30:37 +0100 |
| commit | 916c512bf5a31041ac87296e1382f84c9367b955 (patch) | |
| tree | 9541124a1339ce6e12f46983fce875b41d1fff00 /src/pages/thematique/[slug].tsx | |
| parent | 79f7688703fe42ce87c92567f5bc92b6691eaa20 (diff) | |
chore: display initial posts, thematics & topics
By fetching the data in getStaticProps, I can display the data even
for users with Javascript disabled.
Diffstat (limited to 'src/pages/thematique/[slug].tsx')
| -rw-r--r-- | src/pages/thematique/[slug].tsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 166e0bb..d737ea7 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -5,6 +5,7 @@ import Sidebar from '@components/Sidebar/Sidebar'; import Spinner from '@components/Spinner/Spinner'; import { RelatedTopics, ThematicsList, ToC } from '@components/Widgets'; import { + getAllThematics, getAllThematicsSlug, getThematicBySlug, } from '@services/graphql/queries'; @@ -23,7 +24,10 @@ import { useRef } from 'react'; import { useIntl } from 'react-intl'; import { Article, Graph, WebPage } from 'schema-dts'; -const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => { +const Thematic: NextPageWithLayout<ThematicProps> = ({ + thematic, + allThematics, +}) => { const intl = useIntl(); const relatedTopics = useRef<TopicPreview[]>([]); const router = useRouter(); @@ -151,6 +155,7 @@ const Thematic: NextPageWithLayout<ThematicProps> = ({ thematic }) => { > <RelatedTopics topics={relatedTopics.current} /> <ThematicsList + initialData={allThematics} title={intl.formatMessage({ defaultMessage: 'Others thematics', description: 'ThematicPage: thematics list widget title', @@ -175,10 +180,12 @@ export const getStaticProps: GetStaticProps = async ( const translation = await loadTranslation(locale); const { slug } = context.params as PostParams; const thematic = await getThematicBySlug(slug); + const allThematics = await getAllThematics(); const breadcrumbTitle = thematic.title; return { props: { + allThematics, breadcrumbTitle, locale, thematic, |
